package com.ruoyi.activity_record.service.impl;

import java.util.List;

import com.ruoyi.activity.domain.Activity;
import com.ruoyi.activity.mapper.ActivityMapper;
import com.ruoyi.order.domain.Order;
import com.ruoyi.order.mapper.OrderMapper;
import com.ruoyi.user.domain.User;
import com.ruoyi.user.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.activity_record.mapper.ActivityRecordMapper;
import com.ruoyi.activity_record.domain.ActivityRecord;
import com.ruoyi.activity_record.service.IActivityRecordService;

/**
 * 活动参与记录Service业务层处理
 * 
 * @author 张富饶
 * @date 2025-05-22
 */
@Service
public class ActivityRecordServiceImpl implements IActivityRecordService 
{
    @Autowired
    private ActivityRecordMapper activityRecordMapper;
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private ActivityMapper activityMapper;
    /**
     * 查询活动参与记录
     * 
     * @param id 活动参与记录主键
     * @return 活动参与记录
     */
    @Override
    public ActivityRecord selectActivityRecordById(Long id)
    {
        ActivityRecord activityRecord = activityRecordMapper.selectActivityRecordById(id);
//        System.err.println(activityRecord);
        User user = activityRecord.getUser();
        System.err.println(user);
        Long userId = user.getUserId();
        System.out.println(userId);
        User user1 = userMapper.selectUserByUserId(userId);
        System.err.println(user1);
        activityRecord.setUser(user1);
//        ------
        Order order = activityRecord.getOrder();
        Long id1 = order.getId();
        Order order1 = orderMapper.selectOrderById(id1);
        activityRecord.setOrder(order1);
//        -----
        Activity activity = activityRecord.getActivity();
        Long id2 = activity.getId();
        Activity activity1 = activityMapper.selectActivityById(id2);
        activityRecord.setActivity(activity1);
        return activityRecord;
    }

    /**
     * 查询活动参与记录列表
     * 
     * @param activityRecord 活动参与记录
     * @return 活动参与记录
     */
    @Override
    public List<ActivityRecord> selectActivityRecordList(ActivityRecord activityRecord)
    {
        return activityRecordMapper.selectActivityRecordList(activityRecord);
    }

    /**
     * 新增活动参与记录
     * 
     * @param activityRecord 活动参与记录
     * @return 结果
     */
    @Override
    public int insertActivityRecord(ActivityRecord activityRecord)
    {
        return activityRecordMapper.insertActivityRecord(activityRecord);
    }

    /**
     * 修改活动参与记录
     * 
     * @param activityRecord 活动参与记录
     * @return 结果
     */
    @Override
    public int updateActivityRecord(ActivityRecord activityRecord)
    {
        return activityRecordMapper.updateActivityRecord(activityRecord);
    }

    /**
     * 批量删除活动参与记录
     * 
     * @param ids 需要删除的活动参与记录主键
     * @return 结果
     */
    @Override
    public int deleteActivityRecordByIds(Long[] ids)
    {
        return activityRecordMapper.deleteActivityRecordByIds(ids);
    }

    /**
     * 删除活动参与记录信息
     * 
     * @param id 活动参与记录主键
     * @return 结果
     */
    @Override
    public int deleteActivityRecordById(Long id)
    {
        return activityRecordMapper.deleteActivityRecordById(id);
    }
}
